Skip to content

fix(plugin-fetch): avoid relying on global BodyInit in Node projects - #839

Open
stijnvanhulle wants to merge 3 commits into
mainfrom
claude/github-issue-833-ibtsje
Open

fix(plugin-fetch): avoid relying on global BodyInit in Node projects#839
stijnvanhulle wants to merge 3 commits into
mainfrom
claude/github-issue-833-ibtsje

Conversation

@stijnvanhulle

Copy link
Copy Markdown
Contributor

🎯 Changes

@kubb/plugin-fetch and @kubb/plugin-axios emit generated client and serializer files that referenced the global BodyInit type. A Node-only TypeScript project (@types/node without the dom library) declares RequestInit, Request, and Response globally, but not BodyInit, so the generated code failed to type-check with Cannot find name 'BodyInit'.

Both templates now define a module-local RequestBody type derived from RequestInit['body'] and use it everywhere BodyInit was referenced. This resolves the same way BodyInit did in a browser or full-dom project, but no longer depends on a global name a Node-only project doesn't declare.

Fixes #833

Files changed

  • packages/plugin-fetch/templates/fetch.ts and templates/serializers.ts
  • packages/plugin-axios/templates/serializers.ts (shares the same serializer template)
  • Generated snapshots in tests/3.0.x/__snapshots__/ and examples/*/src/gen/.kubb/, refreshed to match
  • docs submodule's snippets/how-to/transport.md updated to match the new type name

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is for the docs (no release).

🤖 Generated with Claude Code

https://claude.ai/code/session_01H2LADp1sJjG9BQz5sQbsBX


Generated by Claude Code

The generated .kubb/client.ts and .kubb/serializers.ts referenced the
global BodyInit type, which a Node-only project (@types/node without
the dom lib) never declares. Both files now use a local RequestBody
type derived from RequestInit['body'], which resolves the same way
without requiring a global BodyInit name. plugin-axios shares the
same serializers.ts template and gets the same fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2LADp1sJjG9BQz5sQbsBX
@codesandbox

codesandbox Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 3, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +0 new · 🟠 ~8 changed · 🔴 -0 removed · 0 flows · 25 files · commit 530d384


Architecture

Architecture diagram for kubb-labs/plugins at 530d384

8 components touched across 5 lanes.

Open full size


Data flow

No data-flow sequence changed in this PR.


Drill down
HTTP Clients — 2 components
🟡 CHANGED @⁠kubb/plugin-fetch

Generates native fetch client and serializer templates using the RequestBody alias instead of global BodyInit.

🟡 CHANGED @⁠kubb/plugin-axios

Generates Axios client code and serializer templates updated to use RequestBody.

Examples & Suites — 6 components
🟡 CHANGED Fetch Client Example

Fetch client example project containing regenerated client and serializer templates.

🟡 CHANGED Axios Client Example

Axios client example project containing regenerated serializer templates.

🟡 CHANGED React Query Example

React Query example suite containing regenerated client and serializer templates.

🟡 CHANGED Advanced PetStore Pipeline

Full multi-plugin pipeline example containing regenerated serializers.

🟡 CHANGED MCP Server Example

MCP integration example containing regenerated serializers.

🟡 CHANGED OpenAPI 3.0 Integration Tests

Snapshot test suite asserting generated output across fetch, axios, react-query, swr, and vue-query plugins.


View

  • Architecture lens
  • Data flow lens
  • Expand every detail
  • Show unchanged neighbours

Tip

GitHub will not let you zoom an image in a comment. The link under each diagram opens it full size on a page of its own, where you can.

🪧 More tips
  • Run PR Lens on your own machine: npx skills add coldteadotai/pr-lens installs the agent skill. Then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Draw a diff before it is even a pull request: npx @coldtea/pr-lens-cli analyze --base origin/main reads the diff with your own model key, and npx @coldtea/pr-lens-cli render .pr-lens/graph.json draws the same lenses on your machine.
  • The boxes under View are live. Tick Architecture lens or Data flow lens to choose which diagrams appear, or Expand every detail to open every drill-down at once. The comment redraws in place a few seconds later.
  • Show unchanged neighbours lists the components this change did not touch alongside the ones it did, so the drill-down shows what the changed code sits next to.
  • The CLI's render picks up .github/pr-lens.yml automatically and applies your corrections (renames, exclusions, lane pins) at draw time.
  • Would you rather run it from CI on a key of your own? Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and a model key in your repository secrets, say GEMINI_API_KEY. The Action asks Gemini by default, or OpenAI and any endpoint speaking /chat/completions through its provider input.
  • PR Lens is free for open source. A star on the repository is what keeps it going.
  • Push a new commit and the whole comment re-renders for the new head. An older run never overwrites a newer one, so a slow render cannot put a stale diagram back.
  • The diagrams follow your GitHub theme, so dark mode gets the dark render and light mode the light one, and the moving dots show this pull request's data in motion.

◈ Rendered by PR Lens · crafted with ❤️ by the Coldtea team · Come say hi on Discord

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec2b376

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@kubb/plugin-fetch Patch
@kubb/plugin-axios Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 15fe174e-4979-4c6a-93b4-781ce53d339a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 312 kB

ℹ️ View Unchanged
Filename Size
packages/plugin-axios/dist/index.cjs 15.5 kB
packages/plugin-axios/dist/index.js 15 kB
packages/plugin-axios/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-cypress/dist/index.cjs 5.71 kB
packages/plugin-cypress/dist/index.js 5.62 kB
packages/plugin-cypress/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-faker/dist/index.cjs 14.5 kB
packages/plugin-faker/dist/index.js 14.4 kB
packages/plugin-faker/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-fetch/dist/index.cjs 15.5 kB
packages/plugin-fetch/dist/index.js 15 kB
packages/plugin-fetch/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-mcp/dist/index.cjs 10 kB
packages/plugin-mcp/dist/index.js 9.54 kB
packages/plugin-mcp/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-msw/dist/index.cjs 5.81 kB
packages/plugin-msw/dist/index.js 5.72 kB
packages/plugin-msw/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-react-query/dist/index.cjs 17.8 kB
packages/plugin-react-query/dist/index.js 17.2 kB
packages/plugin-react-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-redoc/dist/index.cjs 2.21 kB
packages/plugin-redoc/dist/index.js 1.74 kB
packages/plugin-redoc/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-swr/dist/index.cjs 12 kB
packages/plugin-swr/dist/index.js 11.4 kB
packages/plugin-swr/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-ts/dist/index.cjs 23.8 kB
packages/plugin-ts/dist/index.js 23.1 kB
packages/plugin-ts/dist/rolldown-runtime-CNktS9qV.js 291 B
packages/plugin-vue-query/dist/index.cjs 14.8 kB
packages/plugin-vue-query/dist/index.js 14.3 kB
packages/plugin-vue-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-zod/dist/index.cjs 19.7 kB
packages/plugin-zod/dist/index.js 19.6 kB
packages/plugin-zod/dist/rolldown-runtime-C0LytTxp.js 168 B

compressed-size-action

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown
More templates

@kubb/plugin-axios

npm i https://pkg.pr.new/@kubb/plugin-axios@839

@kubb/plugin-cypress

npm i https://pkg.pr.new/@kubb/plugin-cypress@839

@kubb/plugin-faker

npm i https://pkg.pr.new/@kubb/plugin-faker@839

@kubb/plugin-fetch

npm i https://pkg.pr.new/@kubb/plugin-fetch@839

@kubb/plugin-mcp

npm i https://pkg.pr.new/@kubb/plugin-mcp@839

@kubb/plugin-msw

npm i https://pkg.pr.new/@kubb/plugin-msw@839

@kubb/plugin-react-query

npm i https://pkg.pr.new/@kubb/plugin-react-query@839

@kubb/plugin-redoc

npm i https://pkg.pr.new/@kubb/plugin-redoc@839

@kubb/plugin-swr

npm i https://pkg.pr.new/@kubb/plugin-swr@839

@kubb/plugin-ts

npm i https://pkg.pr.new/@kubb/plugin-ts@839

@kubb/plugin-vue-query

npm i https://pkg.pr.new/@kubb/plugin-vue-query@839

@kubb/plugin-zod

npm i https://pkg.pr.new/@kubb/plugin-zod@839

commit: 530d384

The generated .kubb/client.ts declared its own local RequestBody type,
duplicating the one .kubb/serializers.ts already exports. index.ts
re-exports both files, so tsc rejected the ambiguous RequestBody export
with TS2308. The client now imports RequestBody from ./serializers
instead of redeclaring it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xrz6kLobdWn2SzrmZxFudc
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📊 Dependency Size Changes

Note

🎉 This PR removes 104.1 kB of dependencies.

📦 Package 📏 Size
@gunshi/plugin@0.37.1 -75.8 kB
@gunshi/plugin-dryrun@0.37.1 -15.1 kB
@kubb/cli@5.0.6 → @kubb/cli@5.0.4 -9.6 kB
@kubb/core@5.0.6 → @kubb/core@5.0.4 -1.7 kB
@kubb/adapter-oas@5.0.6 → @kubb/adapter-oas@5.0.4 -468 B
@kubb/parser-ts@5.0.6 → @kubb/parser-ts@5.0.4 -468 B
@kubb/plugin-barrel@5.0.6 → @kubb/plugin-barrel@5.0.4 -468 B
@kubb/ast@5.0.6 → @kubb/ast@5.0.4 -468 B
kubb@5.0.6 → kubb@5.0.4 0 B
@kubb/kit@5.0.6 → @kubb/kit@5.0.4 0 B
@kubb/mcp@5.0.6 → @kubb/mcp@5.0.4 0 B
@kubb/renderer-jsx@5.0.6 → @kubb/renderer-jsx@5.0.4 0 B
@kubb/parser-md@5.0.6 → @kubb/parser-md@5.0.4 0 B
unplugin-kubb@5.0.34 → unplugin-kubb@5.0.32 0 B

Total size change: -104.1 kB

Copy link
Copy Markdown
Contributor Author

Build and test on ubuntu-latest is failing (confirmed on one re-run, not a flake) — but it's unrelated to this PR's diff.

What's failing: the Run E2E tests step's pnpm run generate --debug (in tests/e2e, a package this PR never touches) fails with Unknown option: --debug from the kubb CLI.

Why it's not this PR's: pnpm install --frozen-lockfile in CI resolves kubb@5.0.6, even though pnpm-lock.yaml on this branch pins kubb@5.0.4 (same as pnpm-workspace.yaml's catalog ^5.0.4). kubb@5.0.6 apparently dropped/renamed the --debug flag that tests/e2e's workflow step still passes. Since this PR's diff only touches packages/plugin-fetch, packages/plugin-axios, and a handful of generated snapshots, it plays no part in either the version resolution or the CLI flag.

I don't have a ready fix in scope for this PR — the root cause sits in the shared kubb-labs/config setup action's dependency resolution and/or the kubb package's CLI itself, not in kubb-labs/plugins. Two possible fixes for whoever owns that: refresh pnpm-lock.yaml to accept kubb@5.0.6 (if intentional), or drop --debug from tests/e2e's CI step in .github/workflows/pr.yml:306. I'll keep watching this PR.


Generated by Claude Code

kubb v5 dropped the --debug flag in favor of the reporters system
(see kubb-labs/docs migration guide), so tests/e2e's E2E job failed
with "Unknown option: --debug" once CI resolved a kubb version that
enforces unknown-option validation. --reporter file is the documented
replacement, writing the same kind of log.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xrz6kLobdWn2SzrmZxFudc

Copy link
Copy Markdown
Contributor Author

Fixed. --debug was removed in kubb v5 in favor of the reporters system — see the v5 migration guide: --reporter file is the documented replacement, writing the same kind of log. Once CI started resolving a kubb version that validates unknown options, the leftover --debug flag in tests/e2e's workflow step started failing.

Pushed 530d384, updating .github/workflows/pr.yml:306 to pnpm run generate --reporter file.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(plugin-fetch): avoid relying on global BodyInit in Node projects

2 participants